<template>
  <div class="dashboard-container">
        <div style="text-align: center; ">
			<h1>数量统计</h1>
		</div>
		<div class="item">
    		<h3>学校数量</h3>
    		<p>{{schoolCount}}</p>
   	 	</div>
		
  		<div class="item">
    		<h3>全校学院数量</h3>
    		<p>{{academyCount}}</p>
   	 	</div>
		
		<div class="item">
    		<h3>全校班级数量</h3>
    		<p>{{classsCount}}</p>
   	 </div>
		
		<div class="item">
    		<h3>全校学生人数</h3>
    		<p>{{studentCount}}</p>
   	 	</div>
		
		<div class="item">
    		<h3>全校老师人数</h3>
    		<p>{{teacherCount}}</p>
   	 	</div>
   </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'Dashboard',
    computed: {
      ...mapGetters([
        'name'
      ])
    },
    data(){
    	return {
			academyCount: '',
			classsCount: '',
    	studentCount: '',
			teacherCount: '',
			schoolCount:'',
    	}
    },

    mounted(){
      this.$http.get('/api/student/count').then(res => {
      	this.studentCount = res
      })
	  
	  this.$http.get('/api/teacher/count').then(res => {
      	this.teacherCount = res
      })
	  
	  this.$http.get('/api/academy/count').then(res => {
      	this.academyCount = res
      })
	  
	  this.$http.get('/api/classs/count').then(res => {
      	this.classsCount = res
      })
	  this.$http.get('/api/school/count').then(res => {
      	this.schoolCount = res
      })
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard {
    &-container {
      margin: 30px;
    }
    &-text {
      font-size: 30px;
      line-height: 46px;
    }
  }
  
  .item{
    float: left;
    width: 150px;
    text-align: center;
    display: inline-block;
    padding-left: 5px;
    padding-right: 5px;
    border: 1px solid;
    margin-left: 5px;
    margin-right: 5px;
  }
</style>
